using System;
using System.Collections.Generic;
using Heaven.Graphics;

namespace Heaven.Engine
{
    /// <summary>
    /// Provides functionality to render 
    /// content in general way (almost legacy)
    /// </summary>
    public class Scene
    {
        #region Fields

        CoreRenderer renderer = null;
        NodeGroup visuals = null;

        #endregion

        #region Properties
               
        /// <summary>
        /// Visuals are objects which is rendered
        /// </summary>
        public NodeGroup Visuals
        {
            get { return visuals; }
        }

        /// <summary>
        /// The current camera
        /// </summary>
        public Camera Camera
        {
            get { return renderer.Camera; }
            set { renderer.Camera = value; }
        }

        #endregion

        #region Initialization

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="camera">Camera</param>
        public Scene(Camera camera)
        {
            visuals = new NodeGroup();
            renderer = new Renderer(visuals, camera);
            renderer.TargetColor = null;
            renderer.TargetDepth = Double.NaN;
        }

        #endregion

        #region Methods

        /// <summary>
        /// Renders this scene to the frame buffer
        /// </summary>
        /// <param name="device">A graphics device</param>
        public void Render(IDevice device)
        {
            renderer.Target = device.RenderTarget;
            renderer.Render(device);
        }

        #endregion

        #region Debug

        /// <summary>
        /// Gets debug information
        /// </summary>
        /// <returns>Info</returns>
        public string GetStatistics()
        {
            return renderer.GetStatistics();
        }

        #endregion
    }
}
